#!/bin/bash

! [ -n "$1" ] && echo "need config file path" && exit 1
#无论是否设置密码都先移除密码
DEL_LINE=$(nl -b a $1 | grep -v '#' | grep -w requirepass)
[ -n "${DEL_LINE}" ] && sed -i "${DEL_LINE}d" $1
#设置密码
if [ -n "${REDIS_REQUIRE_PASS}" ];
then
    sed -i "\$a requirepass ${REDIS_REQUIRE_PASS}" $1
fi


